

/////////////////////////////////////////////////////////////////////////////

package sheep.model.table;

/////////////////////////////////////////////////////////////////////////////

import javax.swing.table.AbstractTableModel;


/////////////////////////////////////////////////////////////////////////////
import org.jdesktop.swingx.JXTable;

/**
 *
 * @author geek
 * 
 * Classe representant un travailleur repertorie
 */
public class SheepTableModel extends AbstractTableModel {
  private Object[] columnNames;
  private Object[][] data;
  
  public SheepTableModel(Object[] columns, Object[][] data) {
    this.columnNames = columns;
    this.data = data;
  }
  
  public int getRowCount() {
    return data.length;
  }

  public int getColumnCount() {
    return columnNames.length;
  }
  
  public void setData(Object[][] data) {
    this.data = data;
  }
  
  public void setHeaders(Object[] headers) { this.columnNames = headers; }
  public Object[][] getData() { return data; }
  public Object[] getHeaders() { return columnNames; }

  public Object getValueAt(int row, int col) {
    return data[row][col];
  }
  
  public static void setTableHeaders(JXTable table, Object[] headers) {
    for(int i=0; i<headers.length; i++)
      table.getColumnModel().getColumn(i).setHeaderValue(headers[i]);
  }
}

/////////////////////////////////////////////////////////////////////////////
